package share

import (
	"ay-activity/config"
	"ay-activity/utils"
	"time"
)

type Device struct {
	// 主键
	Id            int       `json:"id" gorm:"column:t_id"`
	PhoneType     string    `json:"phoneType" gorm:"column:t_phone_type"`
	SystemVersion string    `json:"systemVersion" gorm:"column:t_system_version"`
	IpAddress     string    `json:"ipAddress" gorm:"column:t_ip_address"`
	RefereeId     int       `json:"refereeId" gorm:"column:t_referee_id"`
	IsUse         int       `json:"isUse" gorm:"column:t_is_use"`
	CreateTime    time.Time `json:"createTime" gorm:"column:t_create_time"`
}

// AddDeviceInfo 添加设备 返回Result
func (device Device) AddDeviceInfo() *utils.Result {
	// 向 t_device 表中插入数据
	device.CreateTime = time.Now()
	tx := config.DB.Table("t_device").Create(&device)
	if tx.Error != nil {
		return utils.Fail("插入失败:"+tx.Error.Error(), 500)
	}
	return utils.OK()
}
